window.onload=function(){
	$(".nav li").hover(function(){
			$(this).find("ul").show();
		},function(){
			$(this).find("ul").hide();
		});
		
//		正则
	/*var reg=/\S/;
	var flag=true;
	$id("uname").onblur=function(){
		if(reg.test(this.value)==false){
			alert("不能为空");
			$id("sub").setAttribute("disabled","disabled");
			flag=false;
		}
	}
	$id("upwd").onblur=function(){
		if(reg.test(this.value)==false){
			alert("不能为空");
			$id("sub").setAttribute("disabled","disabled");
			flag=false;
		}
	}
	$id("sub").onclick=function(){
		if(flag==false){
			alert("不能为空");
			$id("sub").setAttribute("disabled","disabled");
		}
	}*/
	//判断用户是否登录
	var uname = localStorage.getItem("uname");
	if(uname){
		$(".login").html(uname);
	}
	//判断
	$("#sub").click(function(){
		$.ajax({
			type:"post",
			url:"login.php",
			data:{
				uname:$("#uname").val(),
				upwd:$("#upwd").val()
			},
			success:function(res){
				if(res=="0"){
					alert("用户名不存在或用户名错误");
				}else if(res=="1"){
					alert("密码错误");
				}else {
					localStorage.setItem("uname",res);
					location.href = "../index.html";
				}
			}
		})
	});
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}
